﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cpu6502;

namespace NESemu
{
    class Program
    {
        static void Main(string[] args)
        {
            Rom myRom = new Rom();
            myRom.Load("mario.nes");
            
            // Copy data from Rom file into CPU Memory
            int offset = 32768;
            for (int i = 0; i < myRom.RomBankData.Length; i++)
            {
                CPU.Memory[offset + i] = myRom.RomBankData[i];
            }

            // Starting point where the code is
            CPU.PC = 32767;

            // Just loop infinitely.
            while (1 == 1)
            {
                CPU.ExecuteInstruction(CPU.Memory[CPU.PC]);                
                CPU.DumpDebug();
                Console.WriteLine(CPU.OpcodeMapper.Map[CPU.Memory[CPU.PC]].ArgumentLength);
                
                // Move to next instruction
                CPU.PC += 1 + CPU.OpcodeMapper.Map[CPU.Memory[CPU.PC]].ArgumentLength;              
            }
        }
    }
}
